import QtQuick 2.11
//import QtQuick.Controls 1.4

import "."
import "_Global"
import "_Global/Button"

import "_Global/Global.js" as GlobalJS
import "GameJS.js" as GameJS

Item {
    //signal s_ButtonOKClicked()
    property alias text: msgText.text

    function showMsg(ok, discard) {
        buttonOK.visible = ok;
        buttonDiscard.visible = discard;
        visible = true;
    }

    id: root

    Image {
        id: imageBack
        source: Global._FixResourcePath_R("Media/Images/GameMsgBox/Back.png")
        anchors.fill: parent
    }

    TextEdit {
        id: msgText
        x: Global.gamePos.dialogMap.rectTextMsg.x
        y: Global.gamePos.dialogMap.rectTextMsg.y
        width: Global.gamePos.dialogMap.rectTextMsg.width
        height: Global.gamePos.dialogMap.rectTextMsg.height
        font.pixelSize: Global.gamePos.dialogMap.nTextMsgFontSize

        textFormat: Text.RichText
        wrapMode: Text.WordWrap
        readOnly: true
        color : "#FFFFFF"
        //clip: true

        text: ""
        //cursorPosition: 2
        //focus: true

        //anchors.fill: parent
        //font.pixelSize: 22

        onLinkActivated: {
            console.debug(link)
            Qt.openUrlExternally(link);
        }
    }

    ImageButton2 {
        id: buttonOK
        x: Global.gamePos.mapClassInfo.rectStudy.x
        y: Global.gamePos.mapClassInfo.rectStudy.y
        width: Global.gamePos.mapClassInfo.rectStudy.width
        height: Global.gamePos.mapClassInfo.rectStudy.height

        soundEffectClick: Global.resource.effects.effectButton
        bEffectOn: Global.config.bEffectOn

        source: Global._FixResourcePath_R("Media/Images/GameMsgBox/Confirm.png")

        onButtonClicked: {
            root.visible = false;
        }
    }

    ImageButton2 {
        id: buttonDiscard
        x: Global.gamePos.mapClassInfo.rectStudyCard.x
        y: Global.gamePos.mapClassInfo.rectStudyCard.y
        width: Global.gamePos.mapClassInfo.rectStudyCard.width
        height: Global.gamePos.mapClassInfo.rectStudyCard.height

        soundEffectClick: Global.resource.effects.effectButton
        bEffectOn: Global.config.bEffectOn

        source: Global._FixResourcePath_R("Media/Images/GameMsgBox/Discard.png")

        onButtonClicked: {
            Qt.quit();
        }
    }



    Component.onCompleted: {
    }
}

/*
  Text;TextInput;TextEdit;TextField;TextArea;
  */
